<%@ include file="/taglibs.jsp"%>

<TABLE class="table">
	  <TR>
		<TH scope="col" rowspan="2" align="center"><s:text name="file.detail.title8"/></TH>
	    <TH scope="col" rowspan="2" align="center"><s:text name="file.detail.title9"/></TH>
	    <TH scope="col" colspan="2" align="center"><s:text name="file.detail.title10"/></TH>
	    <TH scope="col" colspan="2" align="center"><s:text name="file.detail.title11"/></TH>
	    <TH scope="col" rowspan="2" align="center"><s:text name="file.detail.title16"/></TH>
	    <TH scope="col" rowspan="2" align="center"><s:text name="file.detail.title17"/></TH>
	  </TR>
	  <TR>
		<TH align="center"> <s:text name="file.detail.title12"/></TH>
		<TH align="center"><s:text name="file.detail.title13"/></TH>
		<TH align="center"><s:text name="file.detail.title14"/></TH>
		<TH align="center"><s:text name="file.detail.title15"/></TH>
	  </TR>
	  <s:iterator status="stat" var="workflowProcess" value="workflowProcesses" >
	  <TR>
	    <TD scope="row">
	    	<s:property value="#stat.count" />
	    </TD>
	    <TD>
	    	<s:property value="#workflowProcess.processStatus.description"/>
	    </TD>
	    <TD>
	    	<s:property value="#workflowProcess.processTime"/>
	    </TD>
	    <TD>
	    	<%-- 
	    		[0] --> SUBTIME
	    		[1] --> APPROVED_DATE
	    		[2] --> APPROVED_COMMENT
	    		[3] --> FULLNAME
	    		[4] --> POSITION
	    		[5] --> DESCRIPTION
	    		[6] --> PROCESS_TIME
	    		[7] --> APPROVE_STATUS
	    		[8] --> ID
	    		[9] --> USERNAME
	    	 --%>
			<s:iterator value="voucher" var="item">
				<s:if test="#stat.count == #item[4]">
					    <s:property value="%{#item[0]}" /><br />
				</s:if>
			</s:iterator>   
	    </TD>
	    <TD>
			<s:iterator value="voucher" var="item">
				<s:if test="#stat.count == #item[4] & #item[7]==true ">
					    <div align=center> <s:text name="X"></s:text></div> 
				</s:if>
			</s:iterator> 	
		</TD>				    
	    <TD>
			<s:iterator value="voucher" var="item">
				<s:if test="#stat.count == #item[4] & #item[7]==false ">
					    <div align=center> <s:text name="X"></s:text></div> 
				</s:if>
			</s:iterator> 					    
	    </TD>

	    <TD>
			<s:iterator value="voucher" var="item">
				<s:if test="#stat.count == #item[4]">
					    <s:property value="%{#item[2]}" />
				</s:if>
			</s:iterator>       	
	    </TD>
	    <TD>
			<s:iterator value="voucher" var="item" >
				<s:if test="#stat.count == #item[4]">
						<div>
							<h6><s:property value="%{#item[3]}" /></h6>
						</div>
						<s:if test="%{#item[1] != null}">
						<div>
								<s:property value="%{#item[1]}" />
								<%-- <sec:authorize access="hasAnyRole('ROLE_ADMINISTRATOR','ROLE_MODERATOR')"> --%>	
								<s:if test="%{#item[13] == 1}">			    					    	
									<s:url namespace="/" action="editFileManagement" var="editFileManagementURL">
										<s:param name="id" value="%{#item[8]}"></s:param>
									</s:url>								
							        <s:a href="%{editFileManagementURL}" cssClass="button">
							    		<s:property value="getText('button.edit.date.title')"/>
							    	</s:a>
							    </s:if>
						    	<%-- </sec:authorize> --%>
						</div>
						</s:if>
						
						<s:if test="%{#item[12] != null}">
						
					    	<s:url action="rollback" var="rollbackURL" >
								<s:param name="id" value="%{file.id}"/>
								<s:param name="currentStepId" value="%{@org.apache.commons.lang.StringUtils@split(#item[12])[0]}"/>
								<s:param name="previousStepId" value="%{@org.apache.commons.lang.StringUtils@split(#item[12])[1]}"/>
							</s:url>
							<div>
									<s:a href="%{rollbackURL}" cssClass="button">
							    		<s:property value="getText('file.rollback.title')"/>
							    	</s:a>
					    	</div>
					    </s:if>
				</s:if>
			</s:iterator>    
	    </TD>
	  </TR>
	  
	</s:iterator>
	<TR>
		<th>&nbsp;</th>
		<TH align="center">
    		<s:text name="file.detail.title20"/>
    	</TH>
	    <TH align="center">
			<s:set var="totalRequired" value="0" />
			<s:iterator value="workflowProcesses" var="item">
			     <s:set var="totalRequired" value="%{#totalRequired + #item.processTime}" />
			</s:iterator> 
			<s:property value="%{#totalRequired}" />
		</TH>
		<TH align="center">
			<s:set var="totalDone" value="0" />
			<s:iterator value="voucher" var="item">
			     <s:set var="totalDone" value="%{#totalDone + #item[0]}" />
			</s:iterator>
			<fmt:formatNumber value="${totalDone}" maxFractionDigits="1" />
		</TH>
		<TH colspan="4" align="center">&nbsp;
		</TH>
	</TR>
</TABLE>

<!-- PRINT DOCUMENT -->
<!-- PRINT DOCUMENT -->
<c:if test="${file.category.voucher != null}">
		<s:url action="%{'exportDocFile!exportProcessingReport.html'}" var="exportDocFileURL">
			<s:param name="id" value="%{file.id}"></s:param>
		</s:url>
	<c:if test="${not empty param.id}">
		<s:a href="%{exportDocFileURL}" >
			<img src="${ctx}/images/export_word.png">
		</s:a>
	</c:if>
</c:if>

<c:if test="${file.category.voucher == null}">
	<s:url action="exportVoucher" var="exportVoucherURL">
		<s:param name="id" value="%{file.id}"></s:param>
	</s:url>
	<c:if test="${not empty param.id}">
		<s:a href="%{exportVoucherURL}" cssClass="button">
			<s:property value="getText('button.export.toMSWord.title')"/>
		</s:a>
	</c:if>
</c:if>